/*
 * BlockPersistor.h
 *
 *  Created on: Oct 19, 2013
 *      Author: SG0214746
 */

#ifndef BLOCKPERSISTOR_H_
#define BLOCKPERSISTOR_H_

#include "ISerializable.h"
#include "serialization/Serialization.h"
#include <fstream>

class BlockPersistor {
private:
	Binary data;
	Serializer serializer;
	Unserializer unserializer;
	BigInt dataLimit;

public:
	BlockPersistor(BigInt size, float capacity);
	virtual ~BlockPersistor();

	void clear();
	bool serialize(const ISerializable& serializable);
	bool unserialize(ISerializable& serializable);
	BigInt size() const;

	bool save(std::fstream& file);
	bool load(std::fstream& file);
};

#endif /* BLOCKPERSISTOR_H_ */
